package com.junrry.communication.util;

import android.os.Build;
import android.util.Log;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class GPSDataUtils {

    public static final String DATA = "$GNGGA,092120.000,3616.19583,N,12020.14383,E,1,05,8.9,68.6,M,0.0,M,,*4E\n" +
            "$GNGLL,3616.19583,N,12020.14383,E,092120.000,A,A*47\n" +
            "$GPGSA,A,3,13,19,30,194,,,,,,,,,16.2,8.9,13.5*04\n" +
            "$BDGSA,A,3,14,,,,,,,,,,,,16.2,8.9,13.5*25\n" +
            "$GPGSV,3,1,12,05,44,265,,06,43,090,,07,08,084,,12,15,243,20*77\n" +
            "$GPGSV,3,2,12,13,24,182,32,19,16,155,34,20,69,330,,25,11,277,*74\n" +
            "$GPGSV,3,3,12,29,17,319,,30,07,117,28,194,16,175,31,199,,,21*4D\n" +
            "$BDGSV,1,1,02,03,,,29,14,17,222,27*56\n" +
            "$GNRMC,092120.000,A,3616.19583,N,12020.14383,E,0.00,166.25,150425,,,A*71\n" +
            "$GNVTG,166.25,T,,M,0.00,N,0.00,K,A*25\n" +
            "$GNZDA,092120.000,15,04,2025,00,00*45\n" +
            "$GPTXT,01,01,01,ANTENNA OPEN*25";

    public static List<String> getGGA(String msg) {
        List<String> data = new ArrayList<>();
        String [] gpsData = msg.split("\n");
        Log.d("LJMM", "gpsData = " + gpsData.length);
        for (String str : gpsData) {
            Log.d("LJMM", "str = " + str);
            if (str.contains("$GNGGA")) {
                data.addAll(Arrays.asList(str.split(",")));
            }
        }
        return data;
    }

}
